package com.learn.egcar1.base.config;

import com.learn.egcar1.base.listener.AppListener;
import com.learn.egcar1.base.servlet.DataServlet;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SpringWebConfig {
    //注册监听器
    @Bean
    public ServletListenerRegistrationBean servletListenerRegistrationBean(){
        return new ServletListenerRegistrationBean(new AppListener());
    }

    //注册控制器
    @Bean
    public ServletRegistrationBean servletRegistrationBean(){
        ServletRegistrationBean bean = new ServletRegistrationBean(new DataServlet());
        bean.addUrlMappings("/data");


        return bean;
    }
}
